package com.wwj.springcloud.controller;

import com.wwj.springcloud.entity.Dept;
import com.wwj.springcloud.feign.DeptClientServiceFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class DeptController {

    @Autowired
    private DeptClientServiceFeign deptClientServer;

    // http://localhost/customer/dept/add?name=wwj&dbName=2233
    @RequestMapping("/customer/dept/add")
    public boolean add(Dept dept) {
        System.out.println("-------------");
        System.out.println(dept);
        System.out.println("-------------");
        return deptClientServer.addDeptFeign(dept);
    }

    // http://localhost/customer/dept/get/2
    @RequestMapping("/customer/dept/get/{id}")
    public Dept get(@PathVariable("id") Long id) {
        System.out.println("-------------------" + id + "-------------------");
        return deptClientServer.queryByIdFeign(id);
    }

    // http://localhost/customer/dept/getAllDept
    @RequestMapping("/customer/dept/getAllDept")
    public List<Dept> getAll() {
        return deptClientServer.queryAllFeign();
    }


}
